<!-- 
  v-bind  :   动态的绑定一个或多个 attribute，也可以是组件的 prop
  $attrs  :   包含了所有非 prop 的属性

-->
<template>
    <svg aria-hidden="true" :class="svgClass" v-bind="$attrs">
        <use :xlink:href="symbolId" />
    </svg>
</template>
<script lang="ts" setup>
import { computed, defineProps } from 'vue'
const props = defineProps({
    iconName: {
        type: String,
        default: '',
    },
    iconClass: {
        type: String,
        default: '',
    },
})

const symbolId = computed(() => {
    return `#icon-${props.iconName}`
})
const svgClass = computed(() => {
    if (props.iconClass) {
        return 'svg-icon ' + props.iconClass
    } else {
        return 'svg-icon'
    }
})
</script>
<style lang="scss" scoped>
.svg-icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    fill: currentColor;
    overflow: hidden;
}
</style>
